namespace EastBancTech.InstallerDefinition
{
    using System;
    using System.Security.Cryptography;

    public static class GuidFromName
    {
        static GuidFromName()
        {
            GuidFromName.namespaceGuid = new Guid(0xb37a8ac0, 0x3828, 0x4128, 0xb2, 7, 0xd6, 0xb8, 0x2d, 0x66, 40, 0x25);
        }

        public static Guid Generate(string name)
        {
            return GuidFromName.Generate(GuidFromName.namespaceGuid, name);
        }

        public static Guid Generate(Guid namespaceGuid, string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            byte[] buffer1 = new byte[0x10 + (2 * name.Length)];
            byte[] buffer2 = namespaceGuid.ToByteArray();
            for (int num1 = 0; num1 < 0x10; num1++)
            {
                buffer1[num1] = buffer2[num1];
            }
            for (int num2 = 0; num2 < name.Length; num2++)
            {
                char ch1 = name[num2];
                buffer1[0x10 + (num2 * 2)] = (byte)(ch1 >> 8);
                buffer1[(0x10 + (num2 * 2)) + 1] = (byte)ch1;
            }
            byte[] buffer3 = MD5.Create().ComputeHash(buffer1);
            buffer3[6] = (byte)(buffer3[6] & 15);
            buffer3[6] = (byte)(buffer3[6] | 0x30);
            buffer3[8] = (byte)(buffer3[8] & 0x3f);
            buffer3[8] = (byte)(buffer3[8] | 0x80);
            return new Guid(buffer3);
        }


        private static readonly Guid namespaceGuid;
    }
}

